package zhr.chapter3.jiandanjisuanqi;

public class Expresion {
    private double num1;
    private double num2;
    private char sign;

    public Expresion() {
    }

    public Expresion(double num1, double num2, char sign) {
        this.num1 = num1;
        this.num2 = num2;
        this.sign = sign;
    }

    public double getNum1() {
        return num1;
    }

    public void setNum1(double num1) {
        this.num1 = num1;
    }

    public double getNum2() {
        return num2;
    }

    public void setNum2(double num2) {
        this.num2 = num2;
    }

    public char getSign() {
        return sign;
    }

    public void setSign(char sign) {
        this.sign = sign;
    }
    private double add(){
        return this.num1+this.num2;
    }
    private double sub(){
        return this.num1-this.num2;
    }
    private double mul(){
        return this.num1*this.num2;
    }
    private double div(){
        return this.num1/this.num2;
    }
    public double getResult() {
        double result = 0;
        switch (this.sign) {
            case '+':
                return this.add();
            case '-':
                return this.sub();
            case '*':
                return this.mul();
            case '/':
                return this.div();
        }
    return result;
    }
}
